import logging
import unittest, requests
from loghhh.log import Tools


class wddy(unittest.TestCase):
    jk = 'http://10.59.9.18'

    def setUp(self) -> None:
        Tools().log()
        print('开始')

    def tearDown(self) -> None:
        print('结束')

    # 登录
    sessionid = None
    userid = None

    def test_dy_01(self):
        logging.info('start case test_dy_01')
        r1 = requests.post(url=wddy.jk + '/movieApi/user/v2/login',
                           data={'email': '3601552946@qq.com', 'pwd': 'eWLPHopE945d2ivttHaQTQ=='})
        print(r1.json())
        wddy.sessionid = r1.json()['result']['sessionId']
        wddy.userid = r1.json()['result']['userId']
        print(wddy.userid)
        print(wddy.sessionid)
        logging.info('case test_dy_01 end')

    #     根据用户ID查询用户信息
    """def test_dy_02(self):
        r2 = requests.get(url=wddy.jk+'/movieApi/user/v1/verify/getUserInfoByUserId',
                          headers={'userId': str(wddy.userid), 'sessionId': str(wddy.sessionid)},
                          params={'userId': str(wddy.userid), 'sessionId': str(wddy.sessionid)}
                          )
        print(r2.json())
#         修改密码
#     def test_dy_03(self):
#         r3 = requests.post(url=wddy.jk+'/movieApi/user/v1/verify/modifyUserPwd',
#                            headers={'userId': str(wddy.userid), 'sessionId': str(wddy.sessionid)},
#                            )
#     查看热门电影列表
    movieId=None
    def test_dy_04(self):
        r4 = requests.get(url=wddy.jk+'/movieApi/movie/v2/findHotMovieList',
                          params={'page':1,'count':20})
        print(r4.json())
        wddy.movieId = r4.json()['result'][0]['movieId']
        print(wddy.movieId)

#     查询区域列表
    regionId = None
    def test_dy_05(self):
        r5 = requests.get(url=wddy.jk+'/movieApi/tool/v2/findRegionList')
        print(r5.json())
        wddy.regionId = r5.json()['result'][0]['regionId']
        print(wddy.regionId)
#     根据电影id,区域id 查询播放影院信息
    cinemaId = None
    def test_dy_06(self):
        r6 = requests.get(url=wddy.jk+'/movieApi/movie/v2/findCinemasInfoByRegion',
                          params={'movieId':wddy.movieId,'regionId':wddy.regionId,'page':1,'count':20})
        print(r6.json())
        wddy.cinemaId = r6.json()['result'][0]['cinemaId']
        print(wddy.cinemaId)
    #     根据电影ID和影院ID查询电影排期列表
    pqid = None
    def test_dy_07(self):
        r7 =requests.get(url=wddy.jk+'/movieApi/movie/v2/findMovieSchedule',
                         params={'movieId':wddy.movieId,'cinemaId':wddy.cinemaId})

        print(r7.json())
        wddy.pqid = r7.json()['result'][0]["id"]
        print(wddy.pqid)
#         购票下单
    orderid = None
    def test_dy_08(self):
        print(wddy.userid)
        print(wddy.pqid)
        r8 = requests.post(url=wddy.jk+'/movieApi/movie/v2/verify/buyMovieTickets',
                           headers={'userId': str(wddy.userid), 'sessionId': str(wddy.sessionid)},

                           json={'scheduleId':str(wddy.pqid),'seat':["3-7"],'sign':'e6885d53eeca4956a47caa2d9ffefb7d'})
        print(r8.json())
        wddy.orderid = r8.json()['orderId']

#         查询用户预约电影信息
    def test_dy_09(self):
        r9 = requests.get(url=wddy.jk+'/movieApi/user/v2/verify/findUserReserve',
                          headers={'userId': str(wddy.userid), 'sessionId': str(wddy.sessionid)}
                          )
        print(r9.json())
# 购票记录
    def test_dy_10(self):
        r10 = requests.get(url=wddy.jk+'/movieApi/user/v2/verify/findUserBuyTicketRecord',
                           headers={'userId': str(wddy.userid), 'sessionId': str(wddy.sessionid)},
                           params={'page':1,'count':5,'status':"1"}
                           )
        print(r10.json())
        # 查询看过的电影

    recordId = None
    def test_dy_11(self):
        r11 = requests.get(url=wddy.jk+'/movieApi/user/v2/verify/findSeenMovie',
                           headers={'userId': str(wddy.userid), 'sessionId': str(wddy.sessionid)})
        print(r11.json())
        # wddy.recordId =
    # 我的电影票
    def test_dy_12(self):
        r12 = requests.get(url=wddy.jk+'/movieApi/user/v2/verify/findMyMovieTicket',
                           headers={'userId': str(wddy.userid), 'sessionId': str(wddy.sessionid)}
                           )
        print(r12.json())
        # 查询用户关注电影列表
    def test_dy_13(self):
        r13 = requests.get(url=wddy.jk+'/movieApi/user/v2/verify/findUserFollowMovieList',
                           headers={'userId': str(wddy.userid), 'sessionId': str(wddy.sessionid)},
                           params={'page': 1, 'count': 5, 'status': "1"}
                           )
        print(r13.json())
        # 查询用户关注影院列表
    def test_dy_14(self):
        r14 = requests.get(url=wddy.jk+'/movieApi/user/v2/verify/findUserFollowCinemaList',
                           headers={'userId': str(wddy.userid), 'sessionId': str(wddy.sessionid)},
                           params={'page': 1, 'count': 5, 'status': "1"}
                           )
        print(r14.json())
    # 修改用户生日
    def test_dy_15(self):
        r15 = requests.post(url=wddy.jk+'/movieApi/user/v2/verify/updateUserBirthday',
                            headers={'userId': str(wddy.userid), 'sessionId': str(wddy.sessionid)},
                            data={'birthday':'2025-09-09'})
        print(r15.json())
#     微信登录没做
# 查询取票码
    def test_dy_16(self):
        r16 = requests.get(url=wddy.jk+'/movieApi/user/v2/verify/findExchangeCode',
                           headers={'userId': str(wddy.userid), 'sessionId': str(wddy.sessionid)},
                           params={'recordId':wddy.regionId})
        print(r16.json())
#     查看订单详情
    def test_dy_17(self):
        r17 = requests.get(url=wddy.jk+'/movieApi/user/v2/verify/findBuyTicketRecordByOrderId',
                           headers={'userId': str(wddy.userid), 'sessionId': str(wddy.sessionid)},
                           params={'orderId':wddy.orderid})
        print(r17.json())
# v查询我对电影的评论列表
    def test_dy_18(self):
        r18 = requests.get(url=wddy.jk+'/movieApi/user/v2/verify/findMyMovieCommentList',
                           headers={'userId': str(wddy.userid), 'sessionId': str(wddy.sessionid)},
                           params={'page':1,'count':5})
        print(r18.json())
        # 查询我对影院评论列表
    def test_dy_19(self):
        r19 = requests.get(url=wddy.jk+'/movieApi/user/v2/verify/findMyCinemaCommentList',
                           headers={'userId': str(wddy.userid), 'sessionId': str(wddy.sessionid)},
                           params={'longitude':"0","latitude":"0","page":1,"count":5})
        print(r19.json())

    # # 查询用户观看后的电影评论
    # def test_dy_20(self):
    #
    # 查询正在上映电影列表
    def test_dy_21(self):
        r21 = requests.get(url=wddy.jk+'/movieApi/movie/v2/findReleaseMovieList',
                           headers={'userId': str(wddy.userid), 'sessionId': str(wddy.sessionid)},
                           params={'page':1,'count':5}
                           )
        print(r21.json())

    # 查询即将上映电影列表
    def test_dy_22(self):
        r22 = requests.get(url=wddy.jk + '/movieApi/movie/v2/findComingSoonMovieList',
                           headers={'userId': str(wddy.userid), 'sessionId': str(wddy.sessionid)},
                           params={'page': 1, 'count': 5}
                           )
        print(r22.json())
"""


if __name__ == '__main__':
    unittest.main()
